package io.renren.modules.mapp.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.mapp.entity.CreditScoreEntity;
import io.renren.modules.mapp.service.CreditScoreService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;




/**
 * 
 * 
 * @author cyb
 * @email 
 * @date 2017-08-01 12:48:11
 */
@RestController
@RequestMapping("/mapp/creditscore")
public class CreditScoreController {
	@Autowired
	private CreditScoreService creditScoreService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<CreditScoreEntity> creditScoreList = creditScoreService.queryList(query);
		int total = creditScoreService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(creditScoreList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{openId}")
	public R info(@PathVariable("openId") String openId){
		CreditScoreEntity creditScore = creditScoreService.queryObject(openId);
		
		return R.ok().put("creditScore", creditScore);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	public R save(@RequestBody CreditScoreEntity creditScore){
		creditScoreService.save(creditScore);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	public R update(@RequestBody CreditScoreEntity creditScore){
		creditScoreService.update(creditScore);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	public R delete(@RequestBody String[] openIds){
		creditScoreService.deleteBatch(openIds);
		
		return R.ok();
	}
	
}
